home *** CD-ROM | disk | FTP | other *** search
- Subject: v13i101: Multi-user conferencing system, Part04/05
- Newsgroups: comp.sources.unix
- Sender: sources
- Approved: rsalz@uunet.UU.NET
-
- Submitted-by: Keith Gabryelski <ag@crash.cts.com>
- Posting-number: Volume 13, Issue 101
- Archive-name: conf/part04
-
- #! /bin/sh
- # This is a shell archive, meaning:
- # 1. Remove everything above the #! /bin/sh line.
- # 2. Save the resulting text in a file.
- # 3. Execute the file with /bin/sh (not csh) to create the files:
- # confsig.c
- # confstr.c
- # extern.h
- # structs.h
- export PATH; PATH=/bin:$PATH
- if test -f 'confsig.c'
- then
- echo shar: will not over-write existing file "'confsig.c'"
- else
- cat << \SHAR_EOF > 'confsig.c'
-
- /*
- * conf - An interactive multi-user chat program.
- *
- * conf Copyright (c) 1986, 1987 by Keith Gabryelski
- *
- * Conf is quasi-public domain software; it may be used and copied
- * freely and may be modified to suit the indivuals needs as long
- * as:
- *
- * [1] It is not sold.
- * [2] It is not made part of any licensed product.
- * [3] This header and others like it are not modified or removed.
- * [4] You allow others to use and copy without charge.
- *
- * without expressed written permission from the original
- * author (Keith Gabryelski).
- *
- *
- */
-
- #include "conf.h"
-
- int nsig = 16;
-
- char *sig_list[] =
- {
- "Unkown Signal: 0",
- "Hangup",
- "Interrupt",
- "Quit",
- "Illegal Instruction",
- "Trace Trap",
- "IOT Instruction",
- "EMT Instruction",
- "Floating Point Exception",
- "Kill",
- "Bus Error",
- "Segmentation Violation",
- "Bad Argument To System Call",
- "Write On A Pipe With No One To Read It",
- "Alarm Clock",
- "Software Termination Signal From Kill",
- };
-
- fatal(sig)
- int sig;
- {
- int c, p;
-
- (void)printf("\nFatal Signal %d (%s).\n", sig, putsig(sig));
- make_nice(FALSE);
- if (askdump || (sig == SIGQUIT))
- {
- p = TRUE;
- (void)fputs("dump core? [y] ", stdout);
- while(((c = getchar()) != '\n') && (c != EOF))
- {
- switch(c)
- {
- case 'y':
- case 'Y':
- p = TRUE;
- break;
-
- case 'n':
- case 'N':
- p = FALSE;
- break;
- }
- }
-
- if (p)
- {
- p = kill(cuser.cu_procid, sig);
- if (p <0)
- (void)fprintf(stderr, "%s: Couldn't kill proccess %d (%s)\n",
- progname, cuser.cu_procid, puterr(errno));
- }
- }
- (void) exit(-1);
- }
-
- char *
- putsig(sig)
- int sig;
- {
- static char qwerty[42];
-
- (void)sprintf(qwerty, "Unknown Signal: %d", sig);
-
- return ((unsigned)sig >= nsig) ? qwerty : sig_list[sig];
- }
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'confstr.c'
- then
- echo shar: will not over-write existing file "'confstr.c'"
- else
- cat << \SHAR_EOF > 'confstr.c'
- /*
- * conf - An interactive multi-user chat program.
- *
- * conf Copyright (c) 1986, 1987 by Keith Gabryelski
- *
- * Conf is quasi-public domain software; it may be used and copied
- * freely and may be modified to suit the indivuals needs as long
- * as:
- *
- * [1] It is not sold.
- * [2] It is not made part of any licensed product.
- * [3] This header and others like it are not modified or removed.
- * [4] You allow others to use and copy without charge.
- *
- * without expressed written permission from the original
- * author (Keith Gabryelski).
- *
- */
-
- #include "conf.h"
-
- unsigned int wordlen;
-
- char *
- parsestr(string, length, flags)
- char *string;
- int length, flags;
- {
- static char *retbuf;
- static int buflen = 0;
- static char *prevs;
- static int prevl;
- char *p;
-
- if (buflen == 0)
- retbuf = mymalloc((unsigned)(buflen = PAGESIZ));
-
- p = retbuf;
-
- if (!length)
- {
- string = prevs;
- length = prevl;
- }
-
- while (length && isspace(*string))
- {
- ++string;
- --length;
- }
-
- prevs = string;
- prevl = length;
-
- if (!length)
- {
- wordlen = linelen = 0;
- return NULL;
- }
-
- while (length && ((flags&THEREST) || (!isspace(*string)&&(*string != ',')&&(*string != '='))))
- {
- if (*string == '"')
- {
- ++string; --length;
-
- while (length && (*string != '"'))
- {
- if (*string == '\\')
- {
- ++string; --length;
-
- if (length && isdigit(*string))
- {
- int x, c;
-
- x = (*string++ - '0'); --length;
-
- if (length && isdigit(*string))
- {
- x = (x * 10) + (*string++ - '0'); --length;
-
- if (length && isdigit(*string))
- {
- c = (x * 10) + (*string - '0');
- if (c < 256)
- {
- x = c;
- ++string; --length;
- }
- }
- }
-
- *p++ = x;
- }
- else
- if (length)
- {
- *p++ = *string++; --length;
- }
- }
- else
- {
- *p++ = *string++; --length;
- }
- }
- }
- else
- {
- if (*string == '\\')
- {
- ++string; --length;
-
- if (length && isdigit(*string))
- {
- int x, c;
-
- x = (*string++ - '0'); --length;
-
- if (length && isdigit(*string))
- {
- x = (x * 10) + (*string++ - '0'); --length;
-
- if (length && isdigit(*string))
- {
- c = (x * 10) + (*string - '0');
- if (c < 256)
- {
- x = c;
- ++string; --length;
- }
- }
- }
-
- *p++ = x;
- }
- else
- if (length)
- {
- *p++ = *string++; --length;
- }
- }
- else
- {
- *p++ = *string++; --length;
- }
- }
- }
-
- *p = '\0';
-
- while (length && isspace(*string))
- {
- ++string; --length;
- }
-
- if (length && ((*string == ',') || (*string == '=')))
- {
- ++string; --length;
- }
-
- prevs = string;
- prevl = length;
-
- linelen = length;
- wordlen = p - retbuf;
-
- return wordlen ? retbuf : NULL;
- }
-
- cpystr(to, from, length)
- register char *to, *from;
- register unsigned int length;
- {
- while(length--) *to++ = *from++;
- }
-
- zbuf(ptr, length)
- register char *ptr;
- register unsigned int length;
- {
- while(length--) *ptr = '\0';
- }
-
- cmpdat(dat1, dat2, length)
- register char *dat1, *dat2;
- register int length;
- {
- while (length--)
- if (*dat1++ != *dat2++)
- return FALSE;
-
- return TRUE;
- }
-
- char *
- puterr(error)
- int error;
- {
- static char qwerty[42];
-
- (void)sprintf(qwerty, "Unknown error %d", error);
-
- return ((unsigned)error >= sys_nerr) ? qwerty : sys_errlist[error];
- }
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'extern.h'
- then
- echo shar: will not over-write existing file "'extern.h'"
- else
- cat << \SHAR_EOF > 'extern.h'
- /*
- * conf - An interactive multi-user chat program.
- *
- * conf Copyright (c) 1986, 1987 by Keith Gabryelski
- *
- * Conf is quasi-public domain software; it may be used and copied
- * freely and may be modified to suit the indivuals needs as long
- * as:
- *
- * [1] It is not sold.
- * [2] It is not made part of any licensed product.
- * [3] This header and others like it are not modified or removed.
- * [4] You allow others to use and copy without charge.
- *
- * without expressed written permission from the original
- * author (Keith Gabryelski).
- *
- */
-
- extern errno;
-
- extern struct passwd *getpwuid();
-
- extern FILE *fopen(), *popen();
- extern char *getlogin(), *malloc(), *realloc(), *strchr(), *strrchr();
- extern char *ttyname(), *getenv(), *strcpy(), *strncpy(), *strcat();
-
- #ifdef USE_TERMCAP
- extern char *tgetstr();
- extern void tputs();
- #endif USE_TERMCAP
-
- extern char *sys_errlist[];
- extern int sys_nerr;
- extern long lseek();
- extern void free(), longjmp();
- extern unsigned alarm(), sleep();
-
- extern char *progname;
- extern int log_rfd, log_wfd, usr_fd;
- extern long ourplace;
- extern FILE *rec_fp;
- extern int confing, columns, lines;
- extern char ichar, qchar;
-
- extern char pubkey[], curkey[], pubblock[], curblock[], pubpass[], curpass[];
- extern char *wrdata, replytty[], replyname[];
- extern unsigned wdlen;
-
- extern struct cusrfil cuser, tuser;
- extern struct clogfil clog, tlog;
-
- extern int banner, seeme, informe, warncrypt, autowho, lineinput, beep;
- extern int expand8bit, expandctrl, askdump;
- extern unsigned linelen, wordlen;
-
- extern int nice_exit(), makepass(), enccpy(), write_log();
- extern int version(), do_to(), set_pass(), messptr(), colprnt(), fatal();
- extern int getopts(), getrc(), setopts(), dispchar(), do_ring();
- extern char *logname, *homedir;
- extern char *pager, *shell, *normform, *lineform, *shoutform, *sendform;
- extern char *informform, *recfile;
-
- char *cls;
-
- #ifdef SYSV
- extern struct termio term, saveterm;
- #endif SYSV
-
- #ifdef BSD
- extern struct sgttyb ktty;
- extern int ttyflags;
- #endif BSD
-
- extern char *getline(), *mymalloc(), *myrealloc(), *puterr();
- extern char *getword(), *parsestr(), *putsig();
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'structs.h'
- then
- echo shar: will not over-write existing file "'structs.h'"
- else
- cat << \SHAR_EOF > 'structs.h'
- /*
- * conf - An interactive multi-user chat program.
- *
- * conf Copyright (c) 1986, 1987 by Keith Gabryelski
- *
- * Conf is quasi-public domain software; it may be used and copied
- * freely and may be modified to suit the indivuals needs as long
- * as:
- *
- * [1] It is not sold.
- * [2] It is not made part of any licensed product.
- * [3] This header and others like it are not modified or removed.
- * [4] You allow others to use and copy without charge.
- *
- * without expressed written permission from the original
- * author (Keith Gabryelski).
- *
- */
-
- /*
- * logfile (CONFLOG) structer
- *
- */
-
- struct clogfil
- {
- int type;
- int f_line;
- unsigned int f_usrlen;
- unsigned int f_ttylen;
- unsigned int t_utlen;
- unsigned int messlen;
- char password[8];
- };
-
- /*
- * message type
- *
- */
-
- #define NORMAL 0
- #define SEND 1
- #define SHOUT 2
- #define INFORM 3
-
- /*
- * userfile (CONFUSERS) struct
- *
- */
-
- struct cusrfil
- {
- int cu_flags;
- char cu_cname[MAXNAMELEN];
- char cu_tty[MAXTTYLEN];
- int cu_line;
- short cu_procid;
- };
-
- /*
- * cu_flags
- *
- */
-
- #define USER_OFF 0
- #define USER_ON 1
- #define USER_RECORD 2
-
- /*
- * Structure of valid options
- *
- */
-
- struct varopts
- {
- char *name;
- int type;
- int *var;
- int extra;
- int (*var_func)();
- };
-
- /*
- * Some flags to go with varopt struct
- *
- */
-
- #define BOOLEAN 0
- #define NUMBER 1
- #define STRING 2
- #define VARMASK 3
-
- #define DISPLAY 0
- #define NODISPLAY 4
- #define DISPLAYMASK 4
-
- #define POINTER 1
- #define ROUTINE 2
-
- /*
- * Return values from setops
- *
- */
-
- #define NOOPT 0
- #define FOUNDOPT 1
- #define AMBIGUOUS 2
-
- /*
- * for the who routine
- *
- */
-
- struct whostr
- {
- char name[MAXNAMELEN+1];
- char tty[MAXTTYLEN+1];
- int line;
- int flags;
- };
- SHAR_EOF
- fi # end of overwriting check
- # End of shell archive
- exit 0
-
-